//
//  MCOrderDetailContactView.swift
//  StoreManage
//
//  Created by MC on 2017/12/21.
//  Copyright © 2017年 MC. All rights reserved.
//

import UIKit

class MCOrderDetailContactView: UIView {

    var tempIsContact : Bool = false   // 是否联系人 否则就是收货地址
    
    var isContact : Bool {
        get {
            return tempIsContact
        }
        
        set {
            tempIsContact = newValue
            
            if isContact {
                addressDetailLabel.isHidden = true
                addressLabel.isHidden = true
                signImageView.image = #imageLiteral(resourceName: "Order_contact")

                
            } else {
                addressDetailLabel.isHidden = false
                addressLabel.isHidden = false
                signImageView.image = #imageLiteral(resourceName: "Store_location")
            }
        }
    }
    
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
        backgroundColor = UIColor.white
        
        
        self.addSubview(lineImageView)
        lineImageView.snp.remakeConstraints { (make) ->Void in
            make.left.right.bottom.equalTo(self)
            make.height.equalTo(3)
        }
        
        self.addSubview(signImageView)
        signImageView.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(0)
            make.size.equalTo(CGSize.init(width: 40, height: 40))
        }
        
        self.addSubview(deliveryButton)
        deliveryButton.snp.remakeConstraints { (make) ->Void in
            make.right.equalTo(self).offset(-10)
            make.top.equalTo(0)
            make.height.equalTo(40)
        }
        
        self.addSubview(nameLabel)
        nameLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(signImageView.snp.right)
            make.height.equalTo(40)
            make.centerY.equalTo(deliveryButton)
        }
        
        self.addSubview(addressDetailLabel)
        addressDetailLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(signImageView.snp.right)
            make.right.equalTo(-10)
            make.height.equalTo(20)
            make.bottom.equalTo(-10)
        }
        
        self.addSubview(addressLabel)
        addressLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(signImageView.snp.right)
            make.right.equalTo(-10)
            make.top.equalTo(nameLabel.snp.bottom)
            make.bottom.equalTo(addressDetailLabel.snp.top)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    
    lazy var signImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = UIViewContentMode.center
        return imageView
    }()

    lazy var lineImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Order_line")
        return imageView
    }()

    
    public lazy var nameLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCBlack
        return label
    }()
    
    
    public lazy var addressLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCGray
        return label
    }()
    
    public lazy var addressDetailLabel: UILabel = {
        let label = UILabel.init()
        label.font = MCFont(14)
        label.textColor = UIColor.MCGray
        return label
    }()
    
    
    lazy var deliveryButton: UIButton = {
        let button = UIButton.init(type: UIButtonType.custom)
        button.titleLabel?.font = MCFont(12)
        button.setTitleColor(MCColor_16(colorStr: "FD8748"), for: UIControlState.normal)
        return button
    }()
}

